package io.renren.modules.mqtt;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * //Add the class description
 *
 * @author lhb
 * @date 2023/6/6
 */

@Data
@Component
@Configuration
@ConfigurationProperties("mqtt")
public class MqttConfiguration {


    private String host;
    private String clientid;
    private String username;
    private String password;
    private String topic;
    private int timeout;
    private int keepalive;

    @Bean
    public MqttPushClient getPushClient() {
        MqttPushClient client = new MqttPushClient(host, clientid, username, password, topic, timeout, keepalive);
        // 以/#结尾表示订阅所有以test开头的主题
        // pushClient.subscribe("test/#", 2);
        return client;
    }

}
